/*    */ package com.zimbra.cs.db;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.LogFactory;
/*    */ import java.sql.PreparedStatement;
/*    */ import java.sql.ResultSet;
/*    */ import java.sql.SQLException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DbStatus
/*    */ {
/* 34 */   private static Log mLog = LogFactory.getLog(DbStatus.class);
/*    */   
/*    */   public static boolean healthCheck() {
/* 37 */     boolean result = false;
/* 38 */     PreparedStatement stmt = null;
/* 39 */     ResultSet rs = null;
/* 40 */     DbPool.DbConnection conn = null;
/*    */     try {
/* 42 */       conn = DbPool.getConnection();
/* 43 */       stmt = conn.prepareStatement("SELECT 'foo' AS STATUS");
/* 44 */       rs = stmt.executeQuery();
/* 45 */       if (rs.next())
/* 46 */         result = true;
/*    */     } catch (SQLException e) {
/* 48 */       mLog.warn("Database health check error", e);
/*    */     } catch (ServiceException e) {
/* 50 */       mLog.warn("Database health check error", e);
/*    */     } finally {
/*    */       try {
/* 53 */         DbPool.closeResults(rs);
/*    */       } catch (ServiceException e) {
/* 55 */         mLog.info("Ignoring error while closing database result set during health check", e);
/*    */       }
/*    */       try {
/* 58 */         DbPool.closeStatement(stmt);
/*    */       } catch (ServiceException e) {
/* 60 */         mLog.info("Ignoring error while closing database statement during health check", e);
/*    */       }
/* 62 */       if (conn != null)
/* 63 */         DbPool.quietClose(conn);
/*    */     }
/* 65 */     return result;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/db/DbStatus.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */